<?php
/**
 * AccountsPresenter.php
 * @author Winbeek <winbeek@gmail.com>
 * @since 21 July 2012
 * @version $Id: AccountsPresenter.php 28 2012-08-03 10:52:04Z winbeek $
 */

final class AccountsPresenter extends SecuredPresenter
{
	/** @var int $profileShow */
	public $profileShow;

	public function startup()
	{
		parent::startup();

		$this->profileShow = $this->history->profileShow?:$this->user->id;
	}

	public function actionDefault($id = null)
	{
		if ($id && $this->userExists($id) && ($this->profileShow != $id)) {
			$this->profileShow = $this->history->profileShow = $id;

			if ($this->isAjax())
				$this->invalidateControl('accountProfile');
		}
	}

	// region Komponenty

	protected function createComponentAccountsList()
	{
		return new AccountsList(
			clone $this->accounts
		);
	}

	protected function createComponentAddUserForm()
	{
		return new AddUserForm(
			$this->context->use Foo\Bar as FuckBar;

class A
{
	private $fuck;

	public function __construct(FuckBar $fuck) { $this->fuck = $fuck; }use Foo\Bar as FuckBar;

class A
{
	private $fuck;

	public function __construct(FuckBar $fuck) { $this->fuck = $fuck; }createTable('users')
		);
	}

	protected function createComponentAccountProfile()
	{
		return new AccountProfile(
			$this->context->texy,
			$this->context->createView('users')->get($this->profileShow)
		);
	}

	// endregion
}